<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="resource/css/public.css">
	<link rel="stylesheet" type="text/css" href="resource/css/pagination.css">
    <script type="text/javascript" src="resource/jquery/jquery-1.8.2.js"></script>
	
	<script type="text/javascript" src="resource/javascript/pagination.js"></script>
	
    <style type="text/css">
    	table {
    		margin-top:10px;
    		font-size:14;
    		font-family:'微软雅黑';
    		width:100%;
    		text-align:center;
    	}
    	table tr {
    		height:40px;
    		line-height:40px;
    	}
    	.position {
    		width:20%;
    	}

		
    	
    </style>
	<script type="text/javascript">
	$(document).ready(function () {
		$("td.position").click(function () {
			var p = prompt("请输入职位");
			if(p!=null&&p!="") {
				var o = $(this);
				var sid = o.attr("sid");
				$.ajax({
					type:"post",
					url:"student_updatePosition",
					data:"id="+sid+"&position="+p,
					dataType:"text",
					success:function() {
						o.empty();
						o.append(p);
					}
				})
			}
		});
		
		//初始化，显示第一页
		pagination("student_info", 0, "", "libs/student_service.php?act=pagination");
		$("#1 a").css('background-color','#99A607');
		
		//显示页码
		pageData("pagedata", '"student_info"', "libs/student_service.php?act=getPage", '"libs/student_service.php?act=pagination"');
	});
	
	//全选
	function checkedAll(obj) {
	 	var box = document.getElementsByName(obj)[0];
		var checkbox = document.getElementsByName("checked");
		if (box.checked) {
			for ( var i = 0; i < checkbox.length; i++) {
				checkbox[i].checked = true;
			}
		} else {
			for ( var i = 0; i < checkbox.length; i++) {
				checkbox[i].checked = false;
			}
		} 
	};

	//删除记录
	{literal}
	function delPerson() {
		var checkbox = document.getElementsByName('checked');

		var ary = new Array();

		$("input:checkbox[name='checked'][checked]").each(function(){
				ary.push($(this).val());
			});
			
		if(ary.length > 0){
			$.post('libs/student_service.php?act=delete_student', {id_ary: ary.toString()}, function(data){
				alert("删除成功条数:" + data);
				pagination("student_info", 0, "", "libs/student_service.php?act=pagination");
				$("#1 a").css('background-color','#99A607');
			
				//显示页码
				pageData("pagedata", '"student_info"', "libs/student_service.php?act=getPage", '"libs/student_service.php?act=pagination"');
			});
		}else{
			alert('请您选择要删除的联系人');
		}

		
		/*
		var count = 0;
		for ( var i = 0; i < checkbox.length; i++) {
			if (checkbox[i].checked == true)
				count++;
		}
		if (count != 0) {
			var form = document.getElementsByName(formName)[0];
			form.action = action;
			form.submit();
		} else {
			
		}*/
	}
	{/literal}


	function hover(obj, i) {
		if (i == 1)
			obj.style.background = 'lightblue';
		if (i == 0)
			obj.style.background = '';
	}

	function submit() {
		var v = document.getElementById("studentId").value;
		if(v == "请输入学号") alert(v);
		else {
			document.searchForm.submit();
		}
	}
	</script>
  </head>
  
  <body>
  <input type="button" value="添加学生" onclick="javascript:window.location.href='action.php?page=student_input'"/>
  {if $user_info.type_id == 4}
  <input type="button" value="删除学生" onclick="delPerson();"/>
  {/if}
  <form name="searchForm" style="display:inline-block;" action="action.php?page=search_student" method="post">
  <input id="studentId" type="text" name="id" value="请输入学号" onclick="javascript:this.value='';" onblur="javascript:if(this.value=='')this.value='请输入学号'">
  </form>
  <input type="button" value="查找" onclick="submit();">
  <div class="page hei">学生信息</div>
  <div style="height:380px;">
  <form name="form1">
  <table border=1 cellpadding="0" cellspacing="0">
  <tbody id="student_info">
  <tr>
  <th><input type="checkbox" name="box" onclick="checkedAll('box');"></th>
  <th>学号</th><th>姓名</th><th>联系电话</th><th>职位</th><th>操作</th></tr>
  </tbody>
<!--<td><a href="student_show?id={$s.id}">查看</a></td>-->
  </table>
  <br />
  <div id="pagedata" class="page"><!--实现分页--></div>
  </form>
  </div>
  </body>
</html>
